{% extends 'base.html' %}

{% block title %}作物品种列表{% endblock %}

{% block content %}
<div class="card">
    <div class="card-header bg-primary text-white d-flex justify-content-between align-items-center">
        <h4 class="mb-0">作物品种管理</h4>
        <a href="{{ url_for('data.crop_add') }}" class="btn btn-light">添加作物品种</a>
    </div>
    <div class="card-body">
        <!-- 搜索表单 -->
        <form method="get" class="mb-4">
            <div class="row g-3">
                <div class="col-md-4">
                    <input type="text" class="form-control" name="search_name" value="{{ search_name }}" placeholder="搜索品种名称...">
                </div>
                <div class="col-md-3">
                    <input type="text" class="form-control" name="search_type" value="{{ search_type }}" placeholder="搜索作物类型...">
                </div>
                <div class="col-md-2">
                    <button type="submit" class="btn btn-primary w-100">搜索</button>
                </div>
                <div class="col-md-2">
                    <a href="{{ url_for('data.crop_list') }}" class="btn btn-secondary w-100">重置</a>
                </div>
            </div>
        </form>

        <div class="table-responsive">
            <table class="table table-hover">
                <thead>
                    <tr>
                        <th>品种名称</th>
                        <th>作物类型</th>
                        <th>品种特性</th>
                        <th>产量潜力</th>
                        <th>市场价值</th>
                        <th>创建时间</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                    {% for item in pagination.items %}
                    <tr>
                        <td>{{ item.name }}</td>
                        <td>{{ item.crop_type }}</td>
                        <td>{{ item.characteristics }}</td>
                        <td>{{ item.yield_potential }}</td>
                        <td>{{ item.market_value }}</td>
                        <td>{{ item.created_at.strftime('%Y-%m-%d %H:%M') }}</td>
                        <td>
                            <div class="btn-group btn-group-sm">
                                <a href="{{ url_for('data.crop_edit', id=item.id) }}" class="btn btn-primary">编辑</a>
                                <form action="{{ url_for('data.crop_delete', id=item.id) }}" method="post" class="d-inline" onsubmit="return confirm('确定要删除这个品种吗？');">
                                    <button type="submit" class="btn btn-danger">删除</button>
                                </form>
                            </div>
                        </td>
                    </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>
        
        {% include 'includes/pagination.html' %}
    </div>
</div>
{% endblock %} 